﻿Imports System.IO
Imports System.Net
Imports System.Xml.Serialization
Imports System

Namespace roncliProductions.LibWowArmory

    ''' <summary>
    ''' The base class to inherit XML Armory info from
    ''' </summary>
    ''' <remarks></remarks>
    Public MustInherit Class WowArmoryXML

        Protected strXML As String

        ''' <summary>
        ''' The URL that will open the appropriate armory page
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public MustOverride ReadOnly Property URL() As String

        ''' <summary>
        ''' Retrieves the XML based on the supplied query
        ''' </summary>
        ''' <remarks></remarks>
        Protected Sub Retrieve()
            Dim hwrRequest As HttpWebRequest = CType(HttpWebRequest.Create(URL), HttpWebRequest)
            hwrRequest.Accept = "*/*"
            hwrRequest.UserAgent = "MSIE 7.0"
            hwrRequest.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-us")
            hwrRequest.Headers.Add(HttpRequestHeader.Pragma, "no-cache")
            hwrRequest.Timeout = 10000
            Using wrResponse As WebResponse = hwrRequest.GetResponse()
                Using srReader As New StreamReader(wrResponse.GetResponseStream())
                    strXML = srReader.ReadToEnd()
                End Using
            End Using
            hwrRequest = Nothing
        End Sub

    End Class

End Namespace